﻿
$(document).ready(function () {
    $('#QuoteButton').click(function () {
        submitQuote();
    });

    $('input[type=text]').keypress(function (e) {
        if (e.which == 13) {
            submitQuote();
        }
    });
});

function submitQuote() {
    $("#LoadingAnimation").css("display","");
    $("#QuoteError").css("display", "none");

    $.ajax({
        type: 'POST',
        url: '/Home/GetQuote',
        data: $('input').serialize()
    })
        .done(function (result) {
            updateChart(result);
        })
    .fail(function () {
        $("#QuoteError").css("display", "")
    })
    .always(function () {
        $("#LoadingAnimation").css("display", "none");
    });
}

function updateChart(result) {
    $("#ChartSection").html(result);
}

function showTooltip(x, y, contents) {
    $('<div id="tooltip">' + contents + '</div>').css({
        position: 'absolute',
        display: 'none',
        top: y+5,
        left: x+5,
        border: '1px solid #000',
        padding: '2px',
        opacity: 0.80
    }).appendTo("body").fadeIn(200);
}